package com.celesea.auth.role.v1.controller;

import com.celesea.auth.role.entity.Role;
import com.celesea.auth.role.service.RoleService;
import com.celesea.framework.vo.DictionaryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author JackYuan
 * @create 2017-10-26 23:30
 */
@Api(tags = "角色接口")
@RestController
@RequestMapping("v1/api/roles")
public class RoleApiController {
    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private RoleService roleService;

    @GetMapping("list")
    @ApiOperation(value = "角色列表")
    public List<DictionaryVo> list() {
        List<Role> list = roleService.selectList();
        return list.stream()
                .map(item -> new DictionaryVo(item.getId(), item.getName()))
                .collect(Collectors.toList());
    }

}
